const mongoose = require('mongoose');

const { Schema, model } = mongoose;

const userSchema = new Schema({
    __v: { type: Number, select: false },
    name: { type: String, required: true },
    password: { type: String, required: true, select: false },
    avatar_url: { type: String },///头像
    gender: { type: String, enum: ['male', 'female'], default: 'male', required: true },//性别  enum枚举类型  male男性  female女性
    headline: { type: String },//一句话描述
    locations: { type: [{ type: Schema.Types.ObjectId, ref: 'Topic' }], select: false },//居住地  代表字符串数组类型  数组里面的类型都是字符串类型
    business: { type: Schema.Types.ObjectId, ref: 'Topic', select: false },//行业
    employments: {
        type: [{//教育经历
            company: { type: Schema.Types.ObjectId, ref: 'Topic' },//公司
            job: { type: Schema.Types.ObjectId, ref: 'Topic' },//职位
        }], select: false
    },
    educations: {
        type: [{
            school: { type: Schema.Types.ObjectId, ref: 'Topic' },
            major: { type: Schema.Types.ObjectId, ref: 'Topic' },
            diploma: { type: Number, enum: [1, 2, 3, 4, 5] },
            entrance_year: { type: String },
            graduation_year: { type: String },
        }], select: false
    },//教育经历
    following: {
        type: [{ type: Schema.Types.ObjectId, ref: 'User' }],
        select: false,
    },//关注
    followingTopics: {
        type: [{ type: Schema.Types.ObjectId, ref: 'Topic' }],
        select: false,
    },//关注话题
    likingAnswers: {
        type: [{ type: Schema.Types.ObjectId, ref: 'Topic' }],
        select: false,
    },//赞过的答案
    dislikingAnswers: {
        type: [{ type: Schema.Types.ObjectId, ref: 'Topic' }],
        select: false,
    },//踩过的答案
})

module.exports = model('User', userSchema);